package cn.bdqn.pn.reposity.order;

import cn.bdqn.pn.pojo.order.ChildOrder;
import cn.bdqn.pn.pojo.order.MainOrder;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface MainOrderReposity extends JpaRepository<MainOrder,Integer> , JpaSpecificationExecutor<MainOrder> {
    /**
     * 根据订单号查询子订单
     * @param orderNum
     * @return
     */
    ChildOrder findMainOrderByOrderNum(String orderNum);


    /**
     * 统计近七天每天销售额
     */
    @Query(value = "select m.* from mainOrder as m where payTime between ?1 and SYSDATE()",nativeQuery = true)
    List<MainOrder> getTotalPriceByDay(String a);


    /**
     * 根据订单id和状态
     * 统计总数
     */
    Integer countByMainOrderIdAndStatus(Integer mainOrder,Integer status);





}
